package com.example.liwushuo.bar;

import java.util.ArrayList;
import java.util.List;
import com.example.liwushuo.R;
import com.example.liwushuo.adapter.LittleAdapter;
import com.example.liwushuo.bean.homegridview.DataPost;
import com.example.liwushuo.bean.homegridview.GridItem;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class LittleGoodsBar extends Fragment {

	private String url;
	private PullToRefreshListView listView;
	private List<DataPost> list;
	private LittleAdapter adapter;
	private GridItem gridItem;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		list = new ArrayList<DataPost>();
		gridItem = (GridItem) getArguments().getSerializable("gridItem");
		list.addAll(gridItem.getData().getPosts());
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View view = inflater.inflate(R.layout.bar_little_goods, null);
		initView(view);
		return view;
	}

	private void initView(View view) {

		listView = (PullToRefreshListView) view
				.findViewById(R.id.little_goods_listView);
		adapter = new LittleAdapter(getActivity(), list);
		listView.setAdapter(adapter);
	}

}
